package com.gwtgeo.ui.client.mvp.map;

import org.gwtopenmaps.openlayers.client.Map;
import org.gwtopenmaps.openlayers.client.MapOptions;
import org.gwtopenmaps.openlayers.client.MapWidget;

import com.google.gwt.user.client.ui.SimplePanel;
import com.gwtgeo.ui.client.mvp.windowsmanager.WindowedDisplay;
import com.gwtgeo.ui.client.mvp.windowsmanager.WindowedView;
import com.smartgwt.client.types.HeaderControls;
import com.smartgwt.client.widgets.events.HasClickHandlers;

public class MapView extends WindowedView<SimplePanel> implements
		MapPresenter.Display {

	private MapWidget mapWidget;

	public MapView() {
		super();
	}

	@Override
	public int getWindowHeight() {
		return 600;
	}

	@Override
	public String getWindowTitle() {
		return "Map";
	}

	@Override
	public int getWindowWidth() {
		return 800;
	}

	@Override
	protected SimplePanel buildWidget() {
		return new SimplePanel();
	}

	@Override
	public Map createMapWidget(MapOptions options) {
		if (this.mapWidget != null) {
			this.widget.remove(this.mapWidget);
		}
		this.mapWidget = new MapWidget("788px", "572px", options);
		this.widget.add(mapWidget);
		return mapWidget.getMap();
	}
	
	@Override
	protected void addHeaderControls(java.util.Map<String, HasClickHandlers> headers) {
		window.setHeaderControls(HeaderControls.HEADER_LABEL, headers
				.get(WindowedDisplay.MINIMIZE_HEADER));
	}
}
